class Room
{
	public var name : String;
	public var descr : String;
	public var type : String;
	public var dataUrl : String;
	public var clients : List<ClientData>;
	
	public var msgNum : Int;
	private var lastMsgInHistory : Int;
	public static var msgHistory : IntHash<String>;


	public function new(name:String, descr:String, type:String, dataUrl:String)
	{
		this.name = name;
		this.descr = descr;
		this.type = type;
		this.dataUrl = dataUrl;
		clients = new List<ClientData>();
		msgHistory = new IntHash<String>();
		msgNum = 1;
		lastMsgInHistory = 1;
	}
	
	public function addToMsgHistory(from:String, msg:String)
	{
		if (msgNum - lastMsgInHistory >= 10) 
			msgHistory.remove(lastMsgInHistory);
			
		msgHistory.set(msgNum, from + '|||' + msg);
		lastMsgInHistory ++;
		msgNum ++;
	}
	
	public function incMsgNum() : Int 
	{
		return msgNum ++;
	}
	
	public function getMissedMessages(lastMsg:Int) : List<String>
	{
		var l:List<String> = new List();
		if (msgHistory.exists(lastMsg))
		{
			var i:Int = lastMsg + 1;
			while(i < msgNum)
			{
				l.add(msgHistory.get(i) + "|||" + Std.string(i));
				i ++;
			}
		}
		//trace(l);
		return l;
	}
	
}

/*class AreaRoom extends Room
{
	public function getClientPositions() {} //
	public function moveClient() {} //
}

class NpcAreaRoom extends Room
{
	public function getNpcPositions() {} //
	public function getNpcChanges() {} 
}*/